home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 2010 April
/
PCWorld0410.iso
/
pluginy Firefox
/
735
/
735.xpi
/
chrome
/
answers.jar
/
content
/
options.js
< prev
next >
Wrap
Text File
|
2009-12-13
|
3KB
|
98 lines
// create the base ANSW object if it does not exist.
if (typeof ANSW=="undefined") {
ANSW = new Object();
}
ANSW.optionsDataBoolean = new Array();
// Initializes the options dialog
ANSW.Init = function(nafid,cobrand)
{
ANSW.nafid = nafid;
ANSW.cobrand = cobrand;
};
ANSW.initializeOptions = function()
{
if (ANSW.modifierKey.get()=="ctrlKey")
{
document.getElementById("answers.action.altclick").label="The Ctrl key and the left or right mouse button";
document.getElementById("answers.action.default").label="The Ctrl key and the right mouse button";
document.getElementById("alt.caption").label="Ctrl-click";
}
const preferencesService = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService).getBranch("answers.");
if(preferencesService.prefHasUserValue("action.altclick"))
{
var select = preferencesService.getBoolPref("action.altclick");
if (select==true)
document.getElementById("answers.radiogroup").selectedIndex = 0;
else
document.getElementById("answers.radiogroup").selectedIndex = 1;
}
else
document.getElementById("answers.radiogroup").selectedIndex = 0;
if(preferencesService.prefHasUserValue("view.answertip"))
{
var select = preferencesService.getBoolPref("view.answertip");
if (select==true)
document.getElementById("answertip.radiogroup").selectedIndex = 0;
else
document.getElementById("answertip.radiogroup").selectedIndex = 1;
}
else
document.getElementById("answertip.radiogroup").selectedIndex = 0;
};
// Saves the user's options
ANSW.saveOptions = function()
{
const preferencesService = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService).getBranch("");
var option = null;
ANSW.optionsDataBoolean["answers.action.altclick"] = document.getElementById("answers.action.altclick").selected;
ANSW.optionsDataBoolean["answers.view.answertip"] = document.getElementById("answers.view.answertip").selected;
// Loop through the boolean options
for(option in ANSW.optionsDataBoolean)
{
preferencesService.setBoolPref(option,ANSW.optionsDataBoolean[option]);
}
};
ANSW.modifierKey = {
get: function () {
return this.searchString(this.dataOS) || "an unknown modKey";
},
searchString: function (data) {
for (var i=0;i<data.length;i++) {
var dataString = data[i].string;
if (dataString) {
if (dataString.indexOf(data[i].subString) != -1)
return data[i].modKey;
}
}
},
dataOS : [
{
string: navigator.platform,
subString: "Win",
identity: "Windows",
modKey: "altKey"
},
{
string: navigator.platform,
subString: "Mac",
identity: "Mac",
modKey: "altKey"
},
{
string: navigator.platform,
subString: "Linux",
identity: "Linux",
modKey: "ctrlKey"
}
],
};